<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="beans.CarBean, java.util.List" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="UC_style.css">
<script src="jquery.js"></script>
<script>
$(function(){
    // 给所有 id 以 delete_ 开头的链接绑定点击事件
    $('a[id^="delete_"]').click(function(e){ 
        e.preventDefault(); // 阻止默认跳转行为
        var deleteURL = $(this).attr('href'); // 获取删除链接
        if(confirm('确定删除该条记录吗？')){ // 弹出确认框
            window.location.href = deleteURL; // 跳转到删除链接
        } 
    });
});
</script>
<style>
#div_main1{	
	width:95%;
	background:white;
	padding:10px;
}
.sec{
	height:25px;
	width:150px;
}
.text1{
	height:25px;
	width:150px;
}
.button_Select{
		background-color:RGB(64,158,255);
    	border-width: 1px;
    	color: white;
    	padding: 5px 10px;
    	width: 60px;
   	 	text-align: center;
    	font-size: 16px;
    	border-radius: 12px;
	}
.button_Select:hover {
    background-color:RGB(38,169,226);
}
.a1{
	font-size:13px;
}
.a1:hover {
    color: blue;
}
.tr1{
	background-color:white;
	border-bottom: 1px solid #ddd;
}
.tr1:hover{
	background-color: RGB(160,207,255);
	
}
.tr1:hover td{background:none;}

</style>
</head>
<body>
<%
	List <CarBean> list=(List<CarBean>)session.getAttribute("allCars");
%>
	<div class="main" style="background-color:white " >
		
		<div id="header2">
			<img src="img/首页.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
			首页>车辆管理
		</div>
		<div id="div_main1">
		<form action="CarServlet" method="post">
			<table border="1" >
				<tr >
					<td width="300px" align="center" style="border:none;">
						<b>资产编号</b>&nbsp;&nbsp;<input type="text" class="text1" name="asset_number">
					</td >
					<td height="50px"  width="300px" align="center" style="border:none">
						<b>使用状况</b>&nbsp;&nbsp;
					<input type="text" list="condition" name="usage_status">
					<datalist id="condition">
						<option>正常</option>
						<option>维修中</option>
						<option>已出车</option>
					</datalist>
					</td>
					<td width="300px" align="center" style="border:none">
						<b>车辆名称</b>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" class="text1" name="car_name">
					</td>
					
					<td width="300px" align="center" style="border:none">
						<b>车牌号</b>&nbsp;&nbsp;<input type="text" class="text1" name="license_plate">
						<input type="hidden" name="action" value="query"/>
					</td>
					<td width="300px" align="right" style="border:none">
						<input type="submit" class="button_Select" id="select" value="查询" style="margin-right:20px;">
						<input type="button" class="button_Select" id="select" value="新增" onclick="ToaddPage()">
						
					</td>
				</tr>
			</table>
		</form>
		</div>
		<div id="div_main1" style="background-color:white ;">
			<table  border="1" cellspacing = "0" style="font-size:15px;">
				<tr style="background-color:RGB(228,228,228)" >
					<td height="40px"  width="225px" align="center" style="border:none">
						<b>序号</b>
					</td>
					<td width="325px" align="center" style="border:none">
						<b>资产编号</b>
					</td>
					<td width="325px" align="center" style="border:none">
						<b>车辆类别</b>
					</td >
					
					<td width="325px" align="center" style="border:none">
						<b>使用状况</b>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<b>购置日期</b>
					</td>
					<td width="325px" align="center" style="border:none">
						<b>价值</b>
					</td>
					<td width="325px" align="center" style="border:none">
						<b>车辆用途</b>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<b>车牌号</b>
					</td>
					<td width="325px" align="center" style="border:none">
						<b>车辆名称</b>
					</td>
					<td width="325px" align="center" style="border:none">
						<b>管理部门</b>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<b>操作</b>
					</td>
				</tr>
				<% if(list!=null){
					for(int i=0;i<list.size();i++){ %>
				<tr class="tr1" >
					<td height="40px"  width="225px" align="center" style="border:none">
						<%=list.get(i).getCarId()%>
					</td>
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getAssetNumber()%>
					</td>
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getCarType()%>
					</td >
					
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getUsageStatus()%>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getPurchaseDate() %>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getValue()%>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getCarUsage()%>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getLicensePlate()%>
					</td>
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getCarName()%>
					</td>
					<td width="325px" align="center" style="border:none">
						<%=list.get(i).getManagementDepartment()%>
					</td>
					<%String viewURL="CarServlet?action=view&id="+list.get(i).getCarId(); %>
					<%String editURL="CarServlet?action=toEdit&id="+list.get(i).getCarId(); %>
					<%String deleteURL="CarServlet?action=delCar&id="+list.get(i).getCarId()+"&num="+list.get(i).getLicensePlate(); %>
					<td width="325px" align="center" style="border:none">
						<a class="a1" href=<%=viewURL %>>查看</a>
						<a class="a1" href=<%=editURL %>>编辑</a>
						<a class="a1" id="delete_<%=list.get(i).getCarId() %>" style="color:red" href=<%=deleteURL %> >删除</a>
					</td>
				</tr>
			<%  }} //对应以上的for语句%>
			</table>
		</div>
	</div>
<script type="text/javascript">
	function ToaddPage()
	{
		window.location.href="C-add_Car.jsp";
	}
</script>

</body>
</html>